(function ($) {
    /*模板引擎设置*/
    _.templateSettings = {
        interpolate: /\{\{(.+?)\}\}/g
    };


    $.log = function (content, title, format) {
        if (typeof content == 'object') {
            content = JSON.stringify(content, null, '\t');
            if (format) {
                content = content.replace(/\n/g, '<br/>').replace(/\t/g, ' &nbsp; &nbsp; ');
            }
            if (arguments.length > 3) {
                var keywords = Array.prototype.slice.call(arguments, 3);
                for (var i = 0; i < keywords.length; i++) {
                    var keyword = keywords[i];
                    content = content.replace(new RegExp('"' + keyword + '"', "g"), '<span style="background:yellow">"' + keyword + '"</span>');
                }
            }
        }

        // 为消息增加点击事件，开始时折叠消息
        var $msg = $('<p/>').addClass('shortMsg').click(function () {
            $(this).toggleClass('shortMsg');
        });


        var _title = title || ">>";
        $('<span/>').css('color', 'red').text(_title + ' ').appendTo($msg);
        $('<span/>').html(content).appendTo($msg);
        $msg.appendTo('#debugInfo > div');
    };

    $("#reloadPage").on("click", function () {
        location.reload();
    });

})(Zepto);

(function ($) {
    $(document).ready(function () {
        var Student=Backbone.Model.extend({
            defaults:{
                Code:"",
                Name:"",
                Score:0
            }
        });

        var stuModels=[
            {
                Code:"10010",
                Name:"wong",
                Score:530
            },
            {
                Code:"10011",
                Name:"huangjian",
                Score:521
            },
            {
                Code:"10012",
                Name:"lee",
                Score:532
            }
        ];

        var stuList=new Backbone.Collection(stuModels,{
            model:Student
        });

        var stuView=Backbone.View.extend({
            el:"#res",
            render:function(){
                var curList=this.collection.models;
                for(var i= 0;i<curList.length;i++){
                    $(this.el).append(JSON.stringify(curList[i]));
                }
            }
        });

        var stuv=new stuView({
            collection:stuList
        });

        stuv.render();
    });
})(Zepto);